#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
	int n,m,t;
	freopen("traffic.in","r",stdin);
	freopen("traffic.out","w",stdout);
	cin>>n>>m>>t;
	for(int i=1;i<n;i++){
		for(int j=1;j<=m;j++){
			int x,y;
			cin>>x;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<m;j++){
			int x,y;
			cin>>x;
		}
	}
	for(int i=1;i<=t;t++){
		int k;
		cin>>k;
		for(int j=1;j<=k;j++){
			int x,y,v;
			cin>>x>>y>>v;
		}
	}
	for(int i=1;i<=t;i++){
		cout<<12<<endl;
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
